package day0109;

import java.util.Arrays;

public class Test15 {
    public static void main(String[] args) {
        String result=count(9,5000, 688,390);
        System.out.println(result);

        int[]  result2=count2(9,5000, 688,390);
        System.out.println("共有"+result2[0] +"天晴天,"+   result2[1]   +"天雨天");
    }

    static int[]  count2(  int days,  double miles,  double  sunSpeed,  double  rainSpeed ){
        int[]  daysArray=new int[2];
        for(int rainDays=0;   rainDays<=days   ;rainDays++) {
            if (miles == rainDays * rainSpeed + (9 - rainDays) * sunSpeed) {
                daysArray[0]= rainDays;
                daysArray[1]= 9-rainDays;
            }
        }
        return  daysArray;
    }





    //static修飾的方法用"方法名(参数值)" 的格式调用另一个方法，则另一个方法也需要时static修饰的。
    static String  count(  int days,  double miles,  double  sunSpeed,  double  rainSpeed ){
        for(int rainDays=0;   rainDays<=days   ;rainDays++) {
            if (miles == rainDays * rainSpeed + (9 - rainDays) * sunSpeed) {
                return "共有" +(9 - rainDays) +"天晴天," +rainDays +"天雨天";
            }
        }
        return  null;
    }

}
